package controllers

import (
	"net/http"
	"meman/models/auth"
	"github.com/labstack/echo"
	"github.com/chaosue/echo-sessions"
	"meman/sys/basic"
)

func Index(c echo.Context) error   {

	//session 使用
	session := sessions.Default(c)
	var username string
	//中间件已判断,所以这里不需要判断
	if user,ok := session.Get(USER_INFO_SESSION_KEY).(*auth.User); ok {
		username = user.Info.Username
	}

	c.Render(http.StatusOK, "index.tmpl", basic.H{
		"name": username,
	})

	return nil

}

